﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Xml.Linq;

using RioTinto.Data;

namespace RioTinto.Web
{
    public class Global : System.Web.HttpApplication
    {
        protected enum Status
        {
            AccessDenied = 401,
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            ThreadLocalStorageProvider.Current = new WebThreadLocalStorageProvider();
            #region SetContextFactory (Generated: 7/31/2008 1:06:14 PM)
            //DataContextProvider.SetDataContextFactory( new IDataContextFactory() );
            #endregion
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }
        protected void Application_EndRequest(object sender, EventArgs e)
        {
            Status status = (Status)HttpContext.Current.Response.StatusCode;

            switch (status)
            {
                case Status.AccessDenied:
                    Response.Clear();
                    Server.Transfer("~/Pages/AccessDenied.aspx");
                    break;
            }
        }
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            Server.ClearError();
            ErrorUtility.CurrentException = ex;
            Server.Transfer("~/Pages/Error.aspx");
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}